***Note: replicators should set directory to open data 
*cd ""


********** FIGURE 2b: Homotransphobia, Europe **********

*Based on clear all Eurobarometer data, see appendix. Original dataset: https://europa.eu/eurobarometer/surveys/detail/2077. Download through gesis after sign up


clear all
use Eurobarometer.dta

g D=D_sex
g PD=PD_sex

 label var D "Discrimination"
 label var PD "Perceptions of discrimination"


gen Continental=0
replace  Continent=1 if country=="AT" |  country=="BE"  |  country=="DE-E"   |   country=="DE-W"   |  country=="FR"      |  country=="NL"   |  country=="LU"      
	
gen Scandinavia=0
replace  Scandinavia=1 if country=="FI" 	|   country=="DK"   | country=="SE" |  country=="EE"   
gen Mediterranean=0
replace  Mediterranean=1 if country=="ES" |   country=="PT" |   country=="IT"    |  country=="GR"  |  country=="MT"   

gen Anglo_Saxon=0
replace  Anglo_Saxon=1 if country=="GB" |   country=="IE"

gen East_EU=0
replace  East_EU=1 if Continental==0 &  Scandinavia==0 &  Mediterranean==0  & Anglo_Saxon==0 
 

gen Area=.
replace Area=1 if Anglo_Saxon==1
replace Area=2 if Continental==1
replace Area=3 if East_EU==1
replace Area=4 if Mediterranean==1
replace Area=5 if Scandinavia==1

label variable Area "Subcontinent"
la def aria  1 "Anglo-Saxon" 2 "Continental" 3 "Eastern" 4 "Mediterranean" 5 "Nordic", modify
la val Area aria

   grstyle init
 grstyle set legend 2,  nobox
 grstyle set size 8pt: tick_label key_label
 grstyle set size 12pt: heading
 grstyle set size 10pt: subheading axis_title 
 grstyle set graphsize 13cm 11.5cm
 


reg    PD D
ereturn list
loc N6= e(N)
local b= round(_b[D],.001) 
local t = _b[D]/_se[D]  
local p =round(2*ttail(e(df_r),abs(`t')),.001)  


  graph twoway    (lfitci PD  D,   lcol(black)  lwidth(medthick) ciplot(rline) blpattern(dash) acolor(black%65) )     (scatter PD  D if Area==1,       mcolor(black)   msymbol(d))   (scatter PD  D if Area==2,   mcolor(black)    msymbol(S)) (scatter PD  D if Area==3,   mcolor(black)      msymbol(o)) (scatter PD  D if Area==4,   mcolor(black)    msymbol(T)) (scatter PD  D if Area==5,   mcolor(black)    msymbol(X)), yscale(r(0 0.6)) ylabel(0(.2 )0.6) name(a, replace)    legend(position(12) rows(1)  order(3 "Anglo-Saxon" 4 "Continental" 5 "Eastern" 6 "Mediterranean" 7 "Nordic") span) ytitle("Perceptions of discrimination")    xtitle("Discriminatory attitudes")  note("Author's computation based on Eurobarometer." "Plot country-round pairwise correlation. {&rho} = `b' | {it:p-value} = `p' | {it:N} = `N6'." ,size(vsmall) span) subtitle("{bf: Homotransphobia in Europe}") 
graph export "Graph/Figure2b.tif", replace 
graph save "Graph/Figure2b", replace
